package com.sky.kafka.consumer.received;

import com.alibaba.fastjson.JSONObject;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.Optional;

@Component
public class ConsumerReceived {

    //@KafkaListener(topics = {"name", "sky", "poll"})
    public void listen(ConsumerRecord<?, ?> record){
        Optional<?> kafkaMessage = Optional.ofNullable(record.value());
        if (kafkaMessage.isPresent()) {
            Object obj = kafkaMessage.get();
            System.out.println(JSONObject.toJSONString(obj));
        }
    }
}
